const path = require("path");
const htmlwebpackplugin = require("html-webpack-plugin");
const VueLoaderPlugin = require('vue-loader/lib/plugin');

module.exports = {
	entry: path.join(__dirname, "./src/main.js"), // 入口文件，
	output: {
		path: path.join(__dirname, "./dist"), // 输出路径
		filename: "bundle.js"  // 指定输出文件名称
	},
	plugins: [   // 所有的webpack插件的配置节点
		new VueLoaderPlugin(),
		new htmlwebpackplugin({
		template: path.join(__dirname, "./src/index.html"), // 指定模板文件路径
		filename: "index.html", // 设置生成的内存页面名称

	})
	],
	module: {
		rules: [
			{test: /\.css$/, use: ["style-loader", "css-loader"]},
			{test: /\.less$/, use: ["style-loader", "css-loader", "less-loader"]},
			{test: /\.scss$/, use: ["style-loader", "css-loader", "sass-loader"]},
			{test: /\.(jpg|gif|png|bmp|jpeg)$/, use: "url-loader?limit=75948&name=[hash:8]-[name].[ext]"},
			{test: /\.(ttf|eot|svg|woff|woff2)$/, use: "url-loader"},
			{test: /\.js$/, use: "babel-loader", exclude: /node_modules/},
			{test: /\.vue$/,loader: 'vue-loader',
			options: {
				compilerOptions: {
					preserveWhitespace: false}
				}
			  }
		]
	},
	resolve: {
		alias: {
			"vue$": "vue/dist/vue.esm.js"
		}
	}
};
